<template>
  <div class="worktask-designer-taskinfo-container">
    <el-row :gutter="15">
      <el-col :span="5">
        <el-card shadow="hover">
          <template #header>
            <el-descriptions
              class="margin-top"
              title="客户信息"
              :column="3"
              :size="size"
              border
            >
              <template #extra>
                <el-tag class="card-header-tag" type="success">更多详情</el-tag>
              </template>
            </el-descriptions>
          </template>
          <div>
            <p>
              <el-text style="color: #999">客户简称：</el-text>
              <el-text style="color: #333">三利毛巾</el-text>
            </p>
            <p>
              <el-text style="color: #999">客户全称：</el-text>
              <el-text style="color: #333">河北三利毛巾纺织有限公司</el-text>
            </p>
            <p>
              <el-text style="color: #999">所属区域：</el-text>
              <el-text style="color: #333">河北省 > 保定市</el-text>
            </p>
            <p>
              <el-text style="color: #999">地址：</el-text>
              <el-text style="color: #333">竞秀区锦绣街火炬产业园1号楼</el-text>
            </p>
            <p>
              <el-text style="color: #999">电话：</el-text>
              <el-text style="color: #333">0312-3169880 3100868</el-text>
            </p>
            <p>
              <el-text style="color: #999">负责人：</el-text>
              <el-text style="color: #333">崔总 13703280131</el-text>
            </p>
            <p>
              <el-text style="color: #999">业务联系人：</el-text>
              <el-text style="color: #333">王洪义 13703280131</el-text>
            </p>
          </div>
          <el-divider />
          <div>
            <p>
              <el-text style="color: #999">客户所在行业：</el-text>
              <el-text style="color: #333">纺织/机械</el-text>
            </p>
            <p>
              <el-text style="color: #999">主营产品：</el-text>
              <el-text style="color: #333">纺织机械、机头</el-text>
            </p>
            <p>
              <el-text style="color: #999">主要销售区域：</el-text>
              <el-text style="color: #333">全国</el-text>
            </p>
            <p>
              <el-text style="color: #999">主要客户群体：</el-text>
              <el-text style="color: #333">纺织企业</el-text>
            </p>
          </div>
        </el-card>
        <el-card shadow="hover">
          <template #header>
            <el-descriptions
              class="margin-top"
              title="签单业务销售人员信息"
              :column="3"
              :size="size"
              border
            >
              <template #extra>
                <el-tag class="card-header-tag" type="success">
                  查看商机跟进记录
                </el-tag>
              </template>
            </el-descriptions>
          </template>
          <div>
            <p>
              <el-text style="color: #999">员工工号：</el-text>
              <el-text style="color: #333">56413213</el-text>
            </p>
            <p>
              <el-text style="color: #999">部门：</el-text>
              <el-text style="color: #333">
                市场部 > 销售一部 > 销售人员
              </el-text>
            </p>
            <p>
              <el-text style="color: #999">签单人姓名：</el-text>
              <el-text style="color: #333">张三 13703280131</el-text>
            </p>
            <p>
              <el-text style="color: #999">签单人主管姓名：</el-text>
              <el-text style="color: #333">王洪义 13703280131</el-text>
            </p>
            <p>
              <el-text style="color: #999">店长姓名：</el-text>
              <el-text style="color: #333">张三 13703280131</el-text>
            </p>
            <p>
              <el-text style="color: #999">备注：</el-text>
              <el-text style="color: #333">xxxxxxx</el-text>
            </p>
          </div>
        </el-card>
      </el-col>
      <el-col :span="19">
        <el-card shadow="hover">
          <el-descriptions
            class="margin-top"
            title="合同信息"
            :column="3"
            :size="size"
            border
          >
            <el-descriptions-item>
              <template #label>
                <div class="cell-item">
                  <el-icon :style="iconStyle">
                    <user />
                  </el-icon>
                  合同编号
                </div>
              </template>
              AL20245464787125
            </el-descriptions-item>
            <el-descriptions-item>
              <template #label>
                <div class="cell-item">
                  <el-icon :style="iconStyle">
                    <iphone />
                  </el-icon>
                  电话
                </div>
              </template>
              18100000000
            </el-descriptions-item>
            <el-descriptions-item>
              <template #label>
                <div class="cell-item">
                  <el-icon :style="iconStyle">
                    <location />
                  </el-icon>
                  客户联系人
                </div>
              </template>
              Suzhou
            </el-descriptions-item>
            <el-descriptions-item>
              <template #label>
                <div class="cell-item">
                  <el-icon :style="iconStyle">
                    <tickets />
                  </el-icon>
                  业务类型
                </div>
              </template>
              <el-tag size="small">托管类</el-tag>
            </el-descriptions-item>
            <el-descriptions-item>
              <template #label>
                <div class="cell-item">
                  <el-icon :style="iconStyle">
                    <office-building />
                  </el-icon>
                  业务产品
                </div>
              </template>
              阿里托管 > 阿里16800
            </el-descriptions-item>
          </el-descriptions>
        </el-card>
        <el-card shadow="hover">
          <el-descriptions
            class="margin-top"
            title="任务信息"
            :column="3"
            :size="size"
            border
          >
            <el-descriptions-item>
              <template #label>
                <div class="cell-item">
                  <el-icon :style="iconStyle">
                    <user />
                  </el-icon>
                  业务产品
                </div>
              </template>
              阿里16800
            </el-descriptions-item>
            <el-descriptions-item>
              <template #label>
                <div class="cell-item">
                  <el-icon :style="iconStyle">
                    <iphone />
                  </el-icon>
                  合同服务期限
                </div>
              </template>
              2024-05-01至2025-04-30
            </el-descriptions-item>
            <el-descriptions-item>
              <template #label>
                <div class="cell-item">
                  <el-icon :style="iconStyle">
                    <location />
                  </el-icon>
                  计划起始服务日期
                </div>
              </template>
              <el-date-picker
                v-model="value1"
                type="date"
                placeholder="Pick a date"
                :default-value="new Date(2024, 5, 1)"
                disabled
              />
            </el-descriptions-item>
            <el-descriptions-item>
              <template #label>
                <div class="cell-item">
                  <el-icon :style="iconStyle">
                    <tickets />
                  </el-icon>
                  店铺ID
                </div>
              </template>
              <el-tag size="small">AL20240501874654</el-tag>
            </el-descriptions-item>
            <el-descriptions-item>
              <template #label>
                <div class="cell-item">
                  <el-icon :style="iconStyle">
                    <iphone />
                  </el-icon>
                  派单人
                </div>
              </template>
              运营内勤 > 张三
            </el-descriptions-item>
            <el-descriptions-item>
              <template #label>
                <div class="cell-item">
                  <el-icon :style="iconStyle">
                    <location />
                  </el-icon>
                  实际起始服务日期
                </div>
              </template>
              <el-date-picker
                v-model="value1"
                type="date"
                placeholder="Pick a date"
                :default-value="new Date(2024, 5, 1)"
                disabled
              />
            </el-descriptions-item>
            <el-descriptions-item>
              <template #label>
                <div class="cell-item">
                  <el-icon :style="iconStyle">
                    <location />
                  </el-icon>
                  运营店长
                </div>
              </template>
              李四
            </el-descriptions-item>
            <el-descriptions-item>
              <template #label>
                <div class="cell-item">
                  <el-icon :style="iconStyle">
                    <location />
                  </el-icon>
                  运营师
                </div>
              </template>
              赵五
            </el-descriptions-item>
          </el-descriptions>
        </el-card>
        <el-card shadow="hover">
          <el-descriptions
            class="margin-top"
            title="运营师服务小记"
            :column="3"
            :size="size"
            border
          >
            <!-- <template #extra>
              <el-button type="success" @click="handleEdit">
                新增服务小记
              </el-button>
              <el-button type="primary" @click="handleEdit">
                完结服务申请
              </el-button>
            </template> -->
          </el-descriptions>
          <el-table
            v-loading="listLoading"
            :data="list"
            @selection-change="setSelectRows"
          >
            <el-table-column
              align="center"
              label="小记ID"
              prop="recordID"
              show-overflow-tooltip
            />
            <el-table-column
              align="center"
              label="小记时间"
              prop="recordTime"
              show-overflow-tooltip
            />
            <el-table-column
              align="center"
              label="服务小记"
              prop="record"
              show-overflow-tooltip
            />
            <el-table-column
              align="center"
              label="附件"
              prop="recordFile"
              show-overflow-tooltip
            />
            <el-table-column
              align="center"
              label="备注"
              prop="recordMemo"
              show-overflow-tooltip
            />
            <el-table-column
              align="center"
              label="下次服务时间"
              prop="nextTime"
              show-overflow-tooltip
            />
            <el-table-column align="center" label="操作">
              <template #default="{ row }">
                <el-button size="small" @click="handleEdit(row)">
                  查看小记详情
                </el-button>
              </template>
            </el-table-column>
          </el-table>
          <!-- <template #footer>
            <vab-query-form>
              <vab-query-form-left-panel :span="12">
                <el-space />
              </vab-query-form-left-panel>
              <vab-query-form-right-panel :span="12">
                <el-button type="primary" @click="save">
                  提交服务完结申请
                </el-button>
              </vab-query-form-right-panel>
            </vab-query-form>
          </template> -->
        </el-card>
        <el-card shadow="hover">
          <el-descriptions
            class="margin-top"
            title="店铺后台数据"
            :column="3"
            :size="size"
            border
          >
            <!-- <template #extra>
              <el-button type="success" @click="handleEdit">
                新增服务小记
              </el-button>
              <el-button type="primary" @click="handleEdit">
                完结服务申请
              </el-button>
            </template> -->
          </el-descriptions>
          <el-table
            v-loading="listLoading"
            :data="list"
            @selection-change="setSelectRows"
          >
            <el-table-column
              align="center"
              label="小记ID"
              prop="recordID"
              show-overflow-tooltip
              width="80"
            />
            <el-table-column
              align="center"
              label="小记时间"
              prop="recordTime"
              show-overflow-tooltip
            />
            <el-table-column
              align="center"
              label="是否达标行业优选商家"
              prop="record"
              show-overflow-tooltip
            />
            <el-table-column
              align="center"
              label="金冠商品数"
              prop="recordFile"
              show-overflow-tooltip
            />
            <el-table-column
              align="center"
              label="上月在线商品数"
              prop="recordMemo"
              show-overflow-tooltip
            />
            <el-table-column
              align="center"
              label="展现次数"
              prop="nextTime"
              show-overflow-tooltip
            />
            <el-table-column
              align="center"
              label="访客数"
              prop="nextTime"
              show-overflow-tooltip
            />
            <el-table-column
              align="center"
              label="浏览量"
              prop="nextTime"
              show-overflow-tooltip
            />
            <el-table-column
              align="center"
              label="询盘量"
              prop="nextTime"
              show-overflow-tooltip
            />
          </el-table>
          <!-- <template #footer>
            <vab-query-form>
              <vab-query-form-left-panel :span="12">
                <el-space />
              </vab-query-form-left-panel>
              <vab-query-form-right-panel :span="12">
                <el-button type="primary" @click="save">
                  提交服务完结申请
                </el-button>
              </vab-query-form-right-panel>
            </vab-query-form>
          </template> -->
        </el-card>
        <el-card shadow="hover">
          <el-descriptions
            class="margin-top"
            title="客满小记"
            :column="3"
            :size="size"
            border
          >
            <template #extra>
              <el-button type="success" @click="handleEdit">
                新增客满小记
              </el-button>
            </template>
          </el-descriptions>
          <el-table
            v-loading="listLoading"
            :data="list"
            @selection-change="setSelectRows"
          >
            <el-table-column
              align="center"
              label="小记ID"
              prop="recordID"
              show-overflow-tooltip
            />
            <el-table-column
              align="center"
              label="小记时间"
              prop="recordTime"
              show-overflow-tooltip
            />
            <el-table-column
              align="center"
              label="服务小记"
              prop="record"
              show-overflow-tooltip
            />
            <el-table-column
              align="center"
              label="附件"
              prop="recordFile"
              show-overflow-tooltip
            />
            <el-table-column
              align="center"
              label="备注"
              prop="recordMemo"
              show-overflow-tooltip
            />
            <el-table-column
              align="center"
              label="下次服务时间"
              prop="nextTime"
              show-overflow-tooltip
            />
            <!-- <el-table-column align="center" label="操作">
              <template #default="{ row }">
                <el-button size="small" @click="handleEdit(row)">
                  查看/修改小记
                </el-button>
              </template>
            </el-table-column> -->
          </el-table>
          <!-- <template #footer>
            <vab-query-form>
              <vab-query-form-left-panel :span="12">
                <el-space />
              </vab-query-form-left-panel>
              <vab-query-form-right-panel :span="12">
                <el-button type="primary" @click="save">
                  提交服务完结申请
                </el-button>
              </vab-query-form-right-panel>
            </vab-query-form>
          </template> -->
        </el-card>
      </el-col>
    </el-row>
    <!-- <vab-query-form>
      <vab-query-form-left-panel :span="12">
        <el-button :icon="Plus" type="primary" @click="handleEdit">
          添加
        </el-button>
        <el-button :icon="Delete" type="danger" @click="handleDelete">
          批量删除
        </el-button>
      </vab-query-form-left-panel>
      <vab-query-form-right-panel :span="12">
        <el-form :inline="true" :model="queryForm" @submit.prevent>
          <el-form-item>
            <el-input
              v-model.trim="queryForm.title"
              clearable
              placeholder="请输入标题"
            />
          </el-form-item>
          <el-form-item>
            <el-button :icon="Search" type="primary" @click="queryData">
              查询
            </el-button>
          </el-form-item>
        </el-form>
      </vab-query-form-right-panel>
    </vab-query-form> -->
    <!-- <el-row :gutter="15">
      <el-col :span="18">
        <el-table
          v-loading="listLoading"
          :data="list"
          @selection-change="setSelectRows"
        >
          <el-table-column
            align="center"
            show-overflow-tooltip
            type="selection"
          />
          <el-table-column
            align="center"
            label="任务ID"
            prop="id"
            show-overflow-tooltip
          />
          <el-table-column
            align="center"
            label="任务内容"
            prop="title"
            show-overflow-tooltip
          />
          <el-table-column
            align="center"
            label="单位"
            prop="title"
            show-overflow-tooltip
          />
          <el-table-column
            align="center"
            label="计划数量"
            prop="title"
            show-overflow-tooltip
          />
          <el-table-column
            align="center"
            label="制作周期"
            prop="title"
            show-overflow-tooltip
          />
          <el-table-column
            align="center"
            label="备注"
            prop="title"
            show-overflow-tooltip
          />
          <el-table-column
            align="center"
            label="实际数量"
            prop="title"
            show-overflow-tooltip
          />
          <el-table-column align="center" label="操作" width="200">
            <template #default="{ row }">
              <el-button text @click="handleEdit(row)">提交完成</el-button>
            </template>
          </el-table-column>
        </el-table>
      </el-col>
    </el-row> -->
    <edit ref="editRef" @fetch-data="fetchData" />
  </div>
</template>

<script>
  // import { getList, doDelete } from '@/api/storeDetails'
  import Edit from './components/BusinessSatisfactionDetailsEdit'
  import { Delete, Plus, Search } from '@element-plus/icons-vue'

  export default defineComponent({
    name: 'BusinessSatisfactionDetails',
    components: { Edit },
    setup() {
      const route = useRoute()
      const $baseConfirm = inject('$baseConfirm')
      const $baseMessage = inject('$baseMessage')

      const state = reactive({
        editRef: null,
        list: [],
        listLoading: true,
        layout: 'total, sizes, prev, pager, next, jumper',
        total: 0,
        selectRows: '',
        queryForm: {
          orderid: 0,
          pageNo: 1,
          pageSize: 10,
          title: '',
        },
      })

      const setSelectRows = (val) => {
        state.selectRows = val
      }
      const handleEdit = (row) => {
        if (row.id) {
          state.editRef.showEdit(row)
        } else {
          state.editRef.showEdit()
        }
      }
      const handleDelete = (row) => {
        if (row.id) {
          $baseConfirm('你确定要删除当前项吗', null, async () => {
            const { msg } = await doDelete({ ids: row.id })
            $baseMessage(msg, 'success', 'vab-hey-message-success')
            await fetchData()
          })
        } else {
          if (state.selectRows.length > 0) {
            const ids = state.selectRows.map((item) => item.id).join()
            $baseConfirm('你确定要删除选中项吗', null, async () => {
              const { msg } = await doDelete({ ids })
              $baseMessage(msg, 'success', 'vab-hey-message-success')
              await fetchData()
            })
          } else {
            $baseMessage('未选中任何行', 'error', 'vab-hey-message-error')
          }
        }
      }
      const handleSizeChange = (val) => {
        state.queryForm.pageSize = val
        fetchData()
      }
      const handleCurrentChange = (val) => {
        state.queryForm.pageNo = val
        fetchData()
      }
      const queryData = () => {
        state.queryForm.pageNo = 1
        fetchData()
      }
      const fetchData = async () => {
        state.listLoading = true
        const {
          data: { total },
        } = await getList(state.queryForm)
        state.list = [
          {
            recordID: 1,
            recordTime: '2024-04-01 14:43:44',
            record: '这里是本次的服务小记',
            recordFile: 2,
            recordMemo: '备注',
            nextTime: '2024-05-01',
          },
        ]
        state.total = total
        state.listLoading = false
      }
      onMounted(() => {
        state.queryForm.orderid = route.query.orderid
        fetchData()
      })

      return {
        ...toRefs(state),
        setSelectRows,
        handleEdit,
        handleDelete,
        handleSizeChange,
        handleCurrentChange,
        queryData,
        fetchData,
        Delete,
        Plus,
        Search,
      }
    },
  })
</script>
